Skip to content

secp256k1: Misc cleanup and modernize.#3712

Merged
davecgh merged 6 commits into
decred:masterfrom
davecgh:secp256k1_misc_cleanup_and_modernize
Jul 8, 2026
Merged

secp256k1: Misc cleanup and modernize.#3712
davecgh merged 6 commits into
decred:masterfrom
davecgh:secp256k1_misc_cleanup_and_modernize

Conversation

@davecgh

@davecgh davecgh commented Jun 28, 2026

Copy link
Copy Markdown
Member

This requires #3711.

This consists of a series of commits that perform some light cleanup and modernization of the secp256k1 code.

The following is a high level overview of the changes:

  • Update comments to use modern documentation links when referencing other methods and symbols
  • Updates tests to consistently make use of the helper methods that parse hex and panic if they represent invalid values
    • Introduce new helpers that allow overflow in addition to those that don't to provide stronger assertions
  • Removes a few field tests that aren't actually testing anything related to the associated methods

See the individual commits for more details.

@davecgh davecgh added this to the 2.2.0 milestone Jun 28, 2026
@davecgh davecgh force-pushed the secp256k1_misc_cleanup_and_modernize branch from 4d3aa9a to cdf2677 Compare June 28, 2026 09:30
Comment thread dcrec/secp256k1/curve.go Outdated
@davecgh davecgh force-pushed the secp256k1_misc_cleanup_and_modernize branch from cdf2677 to 8b33cc5 Compare July 6, 2026 23:28
davecgh added 6 commits July 7, 2026 22:19
This updates the code to use the more modern documentation links when
referencing other methods and symbols.
This updates the tests to consistently make use of the helper methods
that parse hex to 10x26 field vals and panic if they represent invalid
values.

Since some of the tests intentionally involve values that overflow the
max allowed value, the helpers are reworked slightly to either allow
overflow or not and all tests are updated accordingly.

Finally, it renames the helpers that panic to the more canonical mustX
scheme.
This updates the tests to consistently make use of the helper methods
that parse hex to 4x64 field vals and panic if they represent invalid
values.

Since some of the tests intentionally involve values that overflow the
max allowed value, the helpers are reworked slightly to either allow
overflow or not and all tests are updated accordingly.

Finally, it renames the helpers that panic to the more canonical mustX
scheme.
This updates the tests to consistently make use of the helper methods
that parse hex to mod n scalars and panic if they represent invalid
values.

Since some of the tests intentionally involve values that overflow the
max allowed value, the helpers are reworked slightly to either allow
overflow or not and all tests are updated accordingly.
This removes a few 10x26 field tests that aren't actually testing
anything related to the associated methods because they involve
unreduced outputs which are impossible.

The outputs are necessarily reduced when they are parsed by the test
code which mean, at best, it's testing a few isolated cases of parsing
reduction, but that is explicitly tested much more thoroughly elsewhere.
This removes a few 4x64 field tests that aren't actually testing
anything related to the associated methods because they involve
unreduced outputs which are impossible.

The outputs are necessarily reduced when they are parsed by the test
code which mean, at best, it's testing a few isolated cases of parsing
reduction, but that is explicitly tested much more thoroughly elsewhere.
@davecgh davecgh force-pushed the secp256k1_misc_cleanup_and_modernize branch from 8b33cc5 to c2d2b54 Compare July 8, 2026 03:19
@davecgh davecgh merged commit c2d2b54 into decred:master Jul 8, 2026
32 checks passed
@davecgh davecgh deleted the secp256k1_misc_cleanup_and_modernize branch July 8, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants